// 上传模块

// 调用方法：
// $.post('http://http://api.juzhen05.com/admin/matrixbox/updatetoken'


var path = require('path')
var routerApi = require('../../../utils/routeString.js')(__filename, __dirname);

var jwt = require('../../../utils/jwt.js')
var MartixBox = require('../dal/matrixbox.js')

var checkToken = async function (req, res) {
    var token = req.body.token;
    try {
        var tokenData = await jwt.decode(token);
        // 可以使用,并刷新
        var results = await jwt.encode(tokenData.userid)
        return res.send({ code: 1, data: "刷新成功", token: results })
    } catch (error) {
        return res.send({ code: 0, data: "token刷新失败，请重新登陆"});
    }
   
}


server.post({ path: routerApi, name: routerApi }, checkToken);

